set -e

eval "$(/root/miniconda3/bin/conda shell.bash hook)"

if [ ! -d /root/open-webui ]; then
    echo "Please download open-webui git repo to /root first."
    exit 1
fi

cd /root/open-webui/backend

if ! conda env list | grep 'open-webui'; then
    conda create --name open-webui python=3.11 -y
else
    echo "already exists open-webui conda env"
fi

conda activate open-webui &&
    pip install -r requirements.txt -U && sh dev.sh
